package algorithm.poj.p3000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验和教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P3672 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P3672.class.getResource("P3672.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		StringTokenizer st = new StringTokenizer(line);
		int M = Integer.valueOf(st.nextToken());
		int T = Integer.valueOf(st.nextToken());
		int U = Integer.valueOf(st.nextToken());
		int F = Integer.valueOf(st.nextToken());
		int D = Integer.valueOf(st.nextToken());
		int UD = U+D;
		int F2 = F<<1;
		int count = 0;
		int cost = 0;
		for (int i = 0; i < T; i ++) {
			line = stdin.readLine();
			if (line.charAt(0)== 'u' || line.charAt(0)== 'd') {
				if (cost + UD <= M) {
					count ++;
					cost += UD;
				} else {
					break;
				}
			} else {
				if (cost + F2 <= M) {
					count ++;
					cost += F2;
				} else {
					break;
				}
			}
		}
		System.out.println(count);
	}
}